<template>
<div class="m-box">
    <div class="container">
        <div class="m-title">{{ cate.name }}<a href="/?a=list&id=1">查看更多</a></div>
        <div class="m-list">
            <div class="m-each" v-for="(item,index) in currentCategoryCourse" :key="index">
					<a class="m-e-img-a" href="#" @click.prevent="tolink(item.id)" target="_blank"><img :src="item.thumb" :alt="item.title"></a>
					<a class="m-e-title" href="#" @click.prevent="tolink(item.id)" target="_blank">{{ item.title }}</a>
					<div class="m-e-info"><i>¥{{ item.price }}</i><b>{{ item.buy }}人已购买</b></div>
			</div>	
        </div>
    </div>
</div>
</template>
<script>
export default {
    props:['cate'],
    name:'HomeCategoryCourse',
    data(){
        return {
            currentCategoryCourse:[]
        }
    },
    methods:{
        getCourseListByCateId(cid,num=3){
            this.$request.get(`course-by-category?cid=${cid}&num=${num}`)
            .then(res=>{
                this.currentCategoryCourse = res.data
            })
            .catch(function(error){
                console.log(error);
            })
        }
    },
    mounted(){
        this.getCourseListByCateId(this.cate.id)
    }
}
</script>
<style>

</style>